package com.wyp.demo.pattern.proxy.staticproxy;

/**
 * 静态代理,代理类是我们自己编写成的,更像是方法的调用包装,每次为一个接口生成代理类时,我们都需要将同样的横切逻辑进行再次实现.
 *
 * @author: Oliver
 * @time: 2020/12/20/10:42
 */
public class AliPayToBProxy implements IPayment {
    private IPayment payment;

    public AliPayToBProxy(IPayment payment) {
        this.payment = payment;
    }

    @Override
    public void pay() {
        before();
        payment.pay();
        after();
    }

    private void before() {
        System.out.println("调用开始之前,从卡里取钱");
    }

    private void after() {
        System.out.println("调用结束之后,扣钱成功");
    }
}
